function doValidate() {
    $.validity.start();
    $("#name").require("请输入机构名称").maxLength(50,"最长50");
    $("#memo").maxLength(200,"最长200");
    var result = $.validity.end();
    return result.valid;
}

$(function(){
	$('form').submit(function(){
		if(doValidate()){
			$('input[type="submit"]').attr("disabled","disabled");
			$.ajax({
        		type: 'POST',
                url: $('form').attr('action'),
                data: $('form').serialize(),
                success: function(data){
                	if(data.ok){
                		showMessage('机构信息修改成功',function(){
                			closeDialog();
                		});
        	    	}else{
        	    		showMessage('机构信息修改失败：'+data.message,null,'error');
        	    	}
  				},
  				complete:function() {
  					$('input[type="submit"]').removeAttr("disabled");
  				}
   			});
		}
 		return false;
	});
});